package com.yuyu.demo.demo_springboot.controller;

import java.util.List;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yuyu.demo.demo_springboot.domain.Girl;
import com.yuyu.demo.demo_springboot.service.GirlService2;



@RestController
@RequestMapping(value="/girl2")
public class GirlController2 {
	
	@Autowired
	private GirlService2 service;
	
	@GetMapping(value="/list")
	public List<Girl> list(){
		return service.findAll();
	}
	
	@GetMapping(value="/list2")
	public long list2(){
		return service.list2();
	}
	
	@PostMapping(value="/save")
	public long save(
			@Valid Girl gril,BindingResult bingResult
			){
		return service.save(gril);
	}
	
	@PostMapping(value="/save2")
	public long save2(
			){
		return service.save2();
	}
	
	@PostMapping(value="/del")
	public String del(
			@Valid Girl gril
			){
		
		service.delete(gril);
		return "删除成功";
	}

}
